//
// Created by mouse on 2019/12/19.
//

#ifndef NODEMCU_APP_LR_H
#define NODEMCU_APP_LR_H

#include <Arduino.h>
#include <Scheduler.h>
#include <ArduinoJson.h>
#include <IRrecv.h>
#include <IRremoteESP8266.h>
#include <IRac.h>
#include <IRtext.h>
#include <IRutils.h>
#include <Ticker.h>
#include "Utils.h"
#include "app_config.h"
#include "app_mqtt.h"
#include "app_log.h"

#define K_SEND_PIN D1
#define K_RECV_PIN D2

#define K_CAPTURE_BUFFER_SIZE 2048
#define K_TIMEOUT 50
#define K_MIN_UNKNOWN_SIZE 12

#define K_FREQUENCY 38000

class IrResults
{
public:
    decode_type_t decode_type;
    uint16_t bits;
    union
    {
        struct
        {
            uint64_t value;
            uint32_t address;
            uint32_t command;
        };
        uint8_t state[kStateSizeMax];
    };
    uint16_t *rawData;
    uint16_t size;
    bool repeat;
};

class InfraredTask : public Task
{
private:
    NetworkTask *_networkTask;

public:
    InfraredTask(NetworkTask *networkTask);

protected:
    virtual void setup() override;

    virtual void loop() override;
};

#endif //NODEMCU_APP_LR_H
